package com.shyfu.services;

import com.shyfu.dao.BookDAO;
import com.shyfu.entities.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by Svitlana on 04-Apr-14.
 */
@Service
public class BookServiceImpl implements BookService {

    @Autowired
    private BookDAO bookDAO;

    @Override
    @Transactional
    public void addBook(Book book) {
        bookDAO.addBook(book);
    }

    @Override
    @Transactional
    public void removeBook(Book book) {
        bookDAO.removeBook(book);
    }

    @Override
    @Transactional
    public List<Book> getAllBooks() {
        return bookDAO.getAllBooks();
    }

    @Override
    @Transactional
    public Book getBook(long id) {
        return bookDAO.getBook(id);
    }

    @Override
    @Transactional
    public void removeBook(long id) {
        bookDAO.removeBook(id);
    }
}
